package vip.specimen.system.controller.count;

import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import vip.specimen.system.common.annotation.SystemJurisdiction;
import vip.specimen.system.result.JsonResult;
import vip.specimen.system.service.SystemAdvertisingService;
import vip.specimen.system.service.SystemArticleService;
import vip.specimen.system.service.SystemBlogrollService;
import vip.specimen.system.service.SystemResourceService;

import javax.annotation.Resource;

/**
 * *@Author: 余浪人
 * *@Date：2021/4/1 14:32
 * *@Email:yulangren520@Gmail.com
 * *@QQ:1368419640
 **/
@Api(tags = "统计管理")
@RestController
@RequestMapping(value = "/count")
public class CountController {
    @Resource
    private SystemAdvertisingService advertisingService;
    @Resource
    private SystemBlogrollService linkService;
    @Resource
    private SystemResourceService resourceService;
    @Resource
    private SystemArticleService articleService;

    @GetMapping
    @RequiresPermissions(value = "count:select")
    @ApiOperation(value = "简单统计", notes = "统计后台数据库中基础数据量")
    @SystemJurisdiction(resourceType = "button", permissionName = "统计")
    public JsonResult count() {
        JSONObject json = new JSONObject();
        json.put("adTotal", this.advertisingService.count());
        json.put("linkTotal", this.linkService.count());
        json.put("resourceTotal", this.resourceService.count());
        json.put("articleTotal", this.articleService.count());
        return JsonResult.success(json);
    }
}
